package com.xiaoshuidi.cloud.module.member.controller.admin.comment;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.member.controller.admin.comment.vo.*;
import com.xiaoshuidi.cloud.module.member.controller.app.comment.vo.MemberCommentRespVO;
import com.xiaoshuidi.cloud.module.member.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.member.service.comment.MemberCommentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 评价")
@RestController
@RequestMapping(ApiConstants.NAME+"/comment")
@Validated
public class CommentController {
    @Resource
    private MemberCommentService memberCommentService;



    @PostMapping("/comment-statistics")
    @Operation(summary = "综合评分（综合统计页面和普通列表也tab展示的内容）")
    public CommonResult<List<CommentStatisticsVo>> getCommentStatistics(@RequestBody CommentStatisticsReqVo reqVo) {
        return success(memberCommentService.getCommentStatistics(reqVo));
    }



    @PostMapping("/page")
    @Operation(summary = "获得评价分页")
    public CommonResult<PageResult<MemberCommentRespVO>> getCommentPage(@Valid @RequestBody CommentPageVO pageVO) {
        PageResult<MemberCommentRespVO> pageResult = memberCommentService.getCommentPage(pageVO);
        return success(pageResult);
    }

    @PostMapping("/steward-page")
    @Operation(summary = "综合统计页面分页（根据管家得分分页）")
    public CommonResult<PageResult<CommentStewardPageVo>> getStewardPage(@Valid @RequestBody CommentStewardPageReqVo pageVO) {
        PageResult<CommentStewardPageVo> pageResult = memberCommentService.getCommentStewardPage(pageVO);
        return success(pageResult);
    }

}
